package zhang.lao.service.console;

import org.springframework.stereotype.Service;
import zhang.lao.build.mybatis.jdbc.auto.model.WnMachineAppUser;
import zhang.lao.build.mybatis.jdbc.auto.model.WnMachineAppUserExample;
import zhang.lao.build.tool.ListUtils;
import zhang.lao.dao.base.WnMachineAppUserDao;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MachineService {
    @Resource
    private WnMachineAppUserDao wnMachineAppUserDao;
    public WnMachineAppUser getMachineAppUser(String machineId){
        WnMachineAppUserExample wnMachineAppUserExample = new WnMachineAppUserExample();
        wnMachineAppUserExample.createCriteria().andMachineIdEqualTo(machineId);
        List<WnMachineAppUser> wnMachineAppUsers = wnMachineAppUserDao.selectByExample(wnMachineAppUserExample);
        WnMachineAppUser first = ListUtils.getFirst(wnMachineAppUsers);
        if(first==null){
            first = new WnMachineAppUser();
        }
        return first;
    }
}
